/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package service;

import java.sql.Connection;
import java.sql.PreparedStatement;
import util.DatabaseUtil;

/**
 *
 * @author zhang
 */
public class AddCart {
    public Boolean addCart(int bookId,int memberId){
        Connection con=null;
        PreparedStatement ps=null;
        try{
            con=DatabaseUtil.connect();
            ps=con.prepareStatement("insert into cart(bookid,memberid) values(?,?)");
            ps.setInt(1,bookId);
            ps.setInt(2,memberId);
            int i=ps.executeUpdate();
            if(i!=0){
                return true;
            }
        }catch(Exception e){
            e.printStackTrace();
        }finally{
            DatabaseUtil.closeConnection(con, ps,null);
        }
        return false;
    }
}
